/**
 * CoffeeMilk (C) 2010 Amen Hamdan
 * 
 * See the NOTICE file distributed with this work for additional 
 * information regarding copyright ownership.  This file is licenses
 * to you under the Apache License, Version 2.0 (the "License"); you 
 * may not use this file except in compliance with the License.  You 
 * may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.    
 * 
 */
package ameen.rtm.lib.types;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Vector;

public class NotesVector extends Vector<RtmTaskNote> {
	private static final long serialVersionUID 		= 1846229815605885184L;
	public static final String ELEMENT_ADDED   		= "NotesVector.addedElement";
	public static final String ELEMENT_REMOVED 		= "NotesVector.removedElement";
	public static final String ADDED_ALL       		= "NotesVector.addedAll";

	private final PropertyChangeSupport fPropertyChangeSupport = new PropertyChangeSupport(this);
	
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		this.fPropertyChangeSupport.addPropertyChangeListener(listener);
	}
	
	public void removePropertyChangeListener(PropertyChangeListener listener) {
		this.fPropertyChangeSupport.removePropertyChangeListener(listener);
	}
	
	public void add(int index, RtmTaskNote element) {
		super.add(index, element);
		fPropertyChangeSupport.firePropertyChange(ELEMENT_ADDED, null, element);
	};

	public synchronized boolean add(RtmTaskNote e) {
		boolean retVal = super.add(e);
		fPropertyChangeSupport.firePropertyChange(ELEMENT_ADDED, null, e);
		return retVal;
	};
	
	@Override
	public synchronized RtmTaskNote remove(int index) {
		RtmTaskNote retVal = super.remove(index);
		fPropertyChangeSupport.firePropertyChange(ELEMENT_REMOVED, retVal, null);
		return retVal;
	}
	
	@Override
	public boolean remove(Object o) {
		boolean retVal = super.remove(o);
		fPropertyChangeSupport.firePropertyChange(ELEMENT_REMOVED, o, null);
		return retVal;
	}
}
